﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using ESRI.ArcGIS.Geodatabase;

namespace BesAsm.Emgaats.Maintenance
{
    internal class LinkToolSettings : IDisposable
    {
        private IFeatureClass _appendClass;
        private IFeatureClass _archiveClass;

        private bool _disposed = false;

        public LinkToolSettings()
        {
        }

        ~LinkToolSettings()
        {
            Dispose(false);
        }

        #region IDisposable Members

        public void Dispose()
        {
            this.Dispose(true);
            GC.SuppressFinalize(this);
        }

        #endregion

        private void Dispose(bool disposing)
        {
            if (!_disposed)
            {
                if (disposing)
                {
                    // Managed classes
                }

                // Unmanaged classes
                EmgaatsMaintenanceExtension.ReleaseComObject(_appendClass);
                _appendClass = null;
                EmgaatsMaintenanceExtension.ReleaseComObject(_archiveClass);
                _archiveClass = null;

                _disposed = true;
            }
        }

        public IFeatureClass AppendClass
        {
            get
            {
                return _appendClass;
            }

            set
            {
                if (value != _appendClass)
                {
                    EmgaatsMaintenanceExtension.ReleaseComObject(_appendClass);
                    _appendClass = value;
                    EmgaatsMaintenanceExtension.AddReference(_appendClass);
                }
            }
        }

        public IFeatureClass ArchiveClass
        {
            get
            {
                return _archiveClass;
            }

            set
            {
                if (value != _archiveClass)
                {
                    EmgaatsMaintenanceExtension.ReleaseComObject(_archiveClass);
                    _archiveClass = value;
                    EmgaatsMaintenanceExtension.AddReference(_archiveClass);
                }
            }
        }
    }
}
